<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>使用原子组对邮箱进行验证</title>
</head>
<body>
    <input type="text" name="email">
    <span></span>
    <script>
        document.querySelector('[name="email"]').addEventListener('keyup',function(){
            let reg = /^[\w-]+@([\w]+\.)+(com|cn|cc|net|org)$/i;
            document.querySelector('span').innerHTML = reg.test(this.value) ? "正确" : "错误";
        })
    </script>
</body>
</html>